package com.lgkj.ui;


import android.widget.EditText;

import com.lgkj.R;
import com.lgkj.utils.CommonConstant;
import com.lgkj.utils.CommonUtils;
import com.lgkj.utils.HttpUtils;

import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by Administrator on 2018/6/21 0021.
 */

public class OptionActivity extends BaseActivity {
    @BindView(R.id.et_context)
    EditText etContext;

    @Override
    public int getLayoutId() {
        return R.layout.activity_option;
    }

    @Override
    public void initView() {
        String title = getIntent().getStringExtra("base_title");
        if (title == null) {
            title = "意见反馈";
        }
        setTitle(title);
    }

    @Override
    public void initData() {

    }


    @OnClick(R.id.ibt_save)
    public void onClick() {
        showDiaLog("正在登录");
        Map<String, String> map = new HashMap<>();
        map.put("access_token", CommonUtils.getToken(OptionActivity.this));
        map.put("content", etContext.getText().toString());
        HttpUtils.postHttp(map, CommonConstant.ideaAdd, new HttpUtils.HttpCallBack() {
            @Override
            public void successHttp(JSONObject jsonObject, int id) {
                dismissDiaLog();
                toastLong(jsonObject.optString("msg"), 0);
                if (jsonObject.optInt("code") == 0) {
                    finish();
                }
            }

            @Override
            public void errorHttp(String msg) {
                dismissDiaLog();
            }
        });

    }
}
